package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	count := make(map[byte]int)

	if file, err := os.Open("world.txt"); err == nil {
		reader := bufio.NewReader(file)
		for {
			b, err := reader.ReadByte()
			if err == io.EOF {
				break
			}
			if err != nil {
				fmt.Fprintf(os.Stderr, "charcount: %v\n", err)
				os.Exit(1)
			}
			if _, ok := count[b]; ok {
				count[b]++
			} else {
				count[b] = 1
			}
		}

	}

	for k, v := range count {
		fmt.Println(k, " = ", v)
	}

}
